<?php
namespace Andorra\drivers;

use Andorra\dao\Entity;
use Andorra\dao\EntityType;
use Andorra\exceptions\KeyNotFoundException;

class DataValidator {
	private $driver = null;
	
	public function __construct(DataDriver $driver) {
		$this->driver = $driver;
	}
	
	public function getEntities(EntityType $e) {
		$data = $this->driver->getEntities($e);
		
		if (is_array($data))
			return $data;
		
		return array();
	}
	
	public function getEntityById(EntityType $et, $id) {
		$data = $this->driver->getEntityById($et, $id);
		
		if (is_array($data))
			return $data;
		
		throw new KeyNotFoundException($id, $et);
	}
	
	public function getMaxId(EntityType $e) {
		$data = $this->driver->getMaxId($e);
		
		if (is_numeric($data))
			return $data;
		
		return null;
	}
	
	public function putEntity(Entity $e) {
		$this->driver->putEntity($e);
	}
}
?>